<div id="container">
<section id="content">
<script>
	function func_back(subId){
		$("#main_form").prop("action", "manageListVideos");
		$("#hidSubId").val(subId);
		return $("#main_form").submit();
	}

	function func_submit(){
		var isValidTitle = true;
		var isValidYoutubeId = false;
		var isValidDescript = false;

		if($("#txtTitle").val() == ""){
			$("#titleMsg").html("(Vui lòng nhập tiêu đề)");
			isValidTitle = false;
		}else{
			$("#titleMsg").html("");
			isValidTitle = true;
		}

		if($("#txtYoutubeId").val() == ""){
			$("#youtubeMsg").html("(Vui lòng nhập tiêu đề)");
			isValidYoutubeId = false;
		}else{
			$("#youtubeMsg").html("");
			isValidYoutubeId = true;
		}

		if($("#txtDescript").val() == ""){
			$("#descMsg").html("(Vui lòng nhập tiêu đề)");
			isValidDescript = false;
		}else{
			$("#descMsg").html("");
			isValidDescript = true;
		}

		if( isValidTitle && isValidYoutubeId && isValidDescript ){
			return $("#main_form").submit();  
		}      
	}

</script>


	<form id="main_form" method="post" action="confirmEdit">
	<input type="hidden" id="hidSubId" name="subId" value="<?php echo $selectedId;?>"/>
	<input type="hidden" id="hidId" name="id" value="<?php echo $id;?>"/>
	<center>
		<H1>Cập Nhật Video</H1>
	</center>

	<table id="edit_table">
		<tr>
			<td class="edit_column" width="170">Tiêu Đề</td>
			<td style="text-align: left;">
			<?php if($isBack != ""){?>
				<input type="text" id="txtTitle" name="title"
				value="<?php echo html_entity_decode($title, ENT_QUOTES, 'utf-8'); ?>" /><br/>
				<span id="titleMsg" class="errMsg"></span>
			<?php }else{?>
				<input type="text" id="txtTitle" name="title"
				value="<?php echo $video['Video']['m_video_title']; ?>" /><br/>
				<span id="titleMsg" class="errMsg"></span>
			<?php }?>
			</td>
		</tr>
		<tr>
			<td class="edit_column">Mã Youtube</td>
			<td>
			<?php if($isBack != ""){?>
				<input type="text" id="txtYoutubeId" name="youtubeId"
				value="<?php echo $youtubeId; ?>" /><br/>
				<span id="youtubeMsg" class="errMsg"></span>
			<?php }else{?>
				<input type="text" id="txtYoutubeId" name="youtubeId"
				value="<?php echo $video['Video']['m_youtube_id']; ?>" /><br/>
				<span id="youtubeMsg" class="errMsg"></span>
			<?php }?>
			</td>
		</tr>
		<tr>
			<td class="edit_column" style="vertical-align: top;">Mô tả</td>
			<td style="text-align: left;">
				<?php if($isBack != ""){?>
				<textarea style="width: 99%;" rows="20" name="descript" id="txtDescript"><?php echo html_entity_decode($descript, ENT_QUOTES, 'utf-8'); ?></textarea>
				<br/>
				<span id="descMsg" class="errMsg"></span>
				<?php }else{?>
				<textarea style="width: 99%;" rows="20" name="descript" id="txtDescript"><?php echo html_entity_decode($video['Video']['m_video_descript'], ENT_QUOTES, 'utf-8'); ?></textarea>
				<br/>
				<span id="descMsg" class="errMsg"></span>
				<?php }?>
			</td>
		</tr>
		<tr>
			<td colspan="2" style="text-align: center;">
				<button type="button" onclick="func_submit()">Xác Nhận</button>
				<button type="button" onclick="func_back(<?php echo $selectedId;?>)" style="margin-left: 10px;">Quay Lại</button>
			</td>
		</tr>
	</table>
	</form>
</section>
</div>
